package com.apes.scm.voucher.service;

import com.apes.framework.api.DomainService;
import com.apes.scm.masterdata.party.service.SupplierService;
import com.apes.scm.voucher.model.Voucher;
import com.apes.scm.voucher.model.VoucherItem;
import com.apes.scm.voucher.model.VoucherInventory;
import com.apes.scm.voucher.repository.VoucherInventoryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 功能：价值评估服务
 *
 * @author xul
 * @create 2018-03-12 15:24
 */
@Service("valuationService")
public class ValuationService extends DomainService {

    @Autowired
    VoucherInventoryRepository voucherInventoryRepository;

    @Autowired
    SupplierService supplierService;

    public List<VoucherInventory> save(Iterable<VoucherInventory> voucherInventories){
       return voucherInventoryRepository.save(voucherInventories);
    }
    public VoucherInventory save(VoucherInventory voucherInventory) {
        return voucherInventoryRepository.saveAndFlush(voucherInventory);
    }

    public List<VoucherInventory> findByVoucherItem(VoucherItem voucherItem){
        return voucherInventoryRepository.findByVoucherItem(voucherItem);
    }

    public List<VoucherInventory> findByVoucher(Voucher voucher){
        return voucherInventoryRepository.findByVoucher(voucher);
    }
}
